package dev

import (
	"fmt"
	hlp "gitee.com/dreamwood/jxgo/v1/helper"
	"runtime"
)

func Mark() string {
	mark := hlp.CreateRandString(16)
	mark = "======" + mark + "======"
	println(mark)
	return mark
}

func GetLine() int {
	_, _, line, _ := runtime.Caller(1)
	return line
}

func GetFile() string {
	_, file, _, _ := runtime.Caller(1)
	return file
}

func PrintLine() {
	_, _, line, _ := runtime.Caller(1)
	fmt.Println(fmt.Sprintf("Line:%d", line))
}

func PrintFile() {
	_, file, _, _ := runtime.Caller(1)
	fmt.Println(fmt.Sprintf("File:%s", file))
}
func PrintFuncName() {
	pc, _, _, ok := runtime.Caller(1)
	if ok {
		fmt.Println(fmt.Sprintf("FuncName:%s", runtime.FuncForPC(pc).Name()))
	}
}

func PrintFileLine() {
	_, file, line, _ := runtime.Caller(1)
	fmt.Println(fmt.Sprintf("File:%s:%d", file, line))
}
func PrintDebug(v interface{}) {
	_, file, line, _ := runtime.Caller(1)
	fmt.Printf(fmt.Sprintf("%s:%d\n", file, line))
	fmt.Printf("%v\n", v)
}
func PrintDebugGo(v interface{}) {
	_, file, line, _ := runtime.Caller(1)
	fmt.Printf(fmt.Sprintf("%s:%d\n", file, line))
	fmt.Printf("%#v\n", v)
}
func PrintTrace(v interface{}, depth int) {
	for i := 0; i < depth; i++ {
		_, file, line, _ := runtime.Caller(i)
		fmt.Printf(fmt.Sprintf("%s:%d\n", file, line))
	}
	fmt.Printf("%#v\n", v)
}
